package com.snow.springboot.service;

import com.alibaba.excel.context.AnalysisContext;
import com.snow.springboot.entity.NcmsExcelInfo;
import com.snow.springboot.entity.NcmsInfo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @Package: com.snow.springboot.service
 * @ClassName: NcmsListener
 * @Description:
 * @author: lurui
 * @Date: 2018/10/24 下午3:04
 * @version:
 */
@Component
public class NcmsListener extends BaseListenner {
    private List<NcmsInfo> datas = new ArrayList<>();

    @Override
    public void invoke(Object o, AnalysisContext analysisContext) {
        NcmsExcelInfo excelInfo = (NcmsExcelInfo) o;
        NcmsInfo ncmsInfo = new NcmsInfo();
        BeanUtils.copyProperties(excelInfo, ncmsInfo);
        datas.add(ncmsInfo);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }

    @Override
    public List<NcmsInfo> getDatas() {
        return datas;
    }
}
